package com.haiya.visitor.case1;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MaterialSet {
    private List<Material> materials = new ArrayList<>();

    public void add(Material material) {
        materials.add(material);
    }

    public void remove(Material material) {
        materials.remove(material);
    }

    public String accept(Company company) {
        Iterator<Material> iterator = materials.iterator();
        String result = "";
        while(iterator.hasNext()) {
            result += ((Material) iterator.next()).accept(company) + "";
        }
        return result;
    }
}
